package com.hamu.mapper;

import com.hamu.pojo.Article;
import com.hamu.pojo.Media;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MediaMapper {
    @Insert("INSERT INTO media(media_name, media_url, create_user, create_time) " +
            "VALUES (#{mediaName}, #{mediaUrl}, #{createUser}, #{createTime})")
    void add(Media media);

    @Delete("DELETE FROM media WHERE id = #{id}")
    void delete(Integer id);

    @Select("SELECT * FROM media WHERE id = #{id}")
    Media findById(Integer id);

    List<Media> list();

    List<Media> searchMedias(String query);

    @Update("update media set media_url=#{mediaUrl},media_name=#{mediaName} where id=#{id}")
    void update(Media media);
}
